﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using SMS.Core.DataEntity;
using SMS.Common.Search;
using System.Runtime.Serialization;
using System.IO.Ports;

namespace SMS.Contract
{
    [ServiceContract]
    [ServiceKnownType(typeof(Type))]
    [ServiceKnownType(typeof(DarkSearchCondition)), ServiceKnownType(typeof(StringFilterCondition))]
    public interface ISMSService
    {
        #region SMSHandler

        /// <summary> 
        /// 启动短信猫
        /// </summary>
        /// <param name="message">返回信息</param>
        /// <returns></returns>
        [OperationContract]
        bool Start(out string message);

        /// <summary>
        /// 停止短信猫
        /// </summary>
        /// <param name="message">返回信息</param>
        /// <returns></returns>
        [OperationContract]
        bool Stop(out string message);

        /// <summary>
        /// 发送命令
        /// </summary>
        /// <param name="command">命令内容</param>
        /// <param name="message">返回信息</param>
        /// <returns></returns>
        [OperationContract]
        bool SendCommand(string command, out string message);

        /// <summary>
        /// 立即发送短信(等待发送直到处理结束)
        /// </summary>
        /// <param name="number">接收短信号码</param>
        /// <param name="content">要发送的短信内容</param>
        /// <param name="message">返回信息</param>
        /// <returns></returns>
        [OperationContract]
        bool SendMessageImmediately(string number, string content, out string message);

        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="number">接收短信号码</param>
        /// <param name="content">要发送的短信内容</param>
        /// <returns></returns>
        [OperationContract]
        bool SendMessage(string number, string content);        

        /// <summary>
        /// 发送带标记的短信
        /// </summary>
        /// <param name="tag">短信标记</param>
        /// <param name="number">接收短信号码</param>
        /// <param name="content">要发送的短信内容</param>
        /// <returns></returns>
        [OperationContract]
        bool SendMessageWithTag(string tag, string number, string content);

        /// <summary>
        /// 获取当前号码
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        string GetCurrentNumber();

        /// <summary>
        /// 设置当前号码
        /// </summary>
        /// <param name="number"></param>
        [OperationContract]
        void SetCurrentNumber(string number);

        /// <summary>
        /// 获取连接状态
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        bool GetConnectionState();

        /// <summary>
        /// 获取是否自动发送
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        bool GetAutoSendState();

        /// <summary>
        /// 设置是否自动发送
        /// </summary>
        /// <param name="autoSendState"></param>
        [OperationContract]
        void SetAutoSendState(bool autoSendState);

        /// <summary>
        /// 获取是否自动接收
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        bool GetAutoReceiveState();

        /// <summary>
        /// 设置是否自动接收
        /// </summary>
        /// <param name="autoReceiveState"></param>
        [OperationContract]
        void SetAutoReceiveState(bool autoReceiveState);

        #endregion

        #region SendMessage

        /// <summary>
        /// 获取发送短信
        /// </summary>
        /// <param name="sendKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        SendMessage GetSendMessage(string sendKeyid);

        /// <summary>
        /// 获取指定标志的发送状态
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        [OperationContract]
        int GetStatusWithTag(string tag);

        /// <summary>
        /// 获取指定标志的发送短信
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        [OperationContract]
        SendMessage[] GetSendMessageWithTag(string tag);

        /// <summary>
        /// 获取指定事件标识的发送状态
        /// </summary>
        /// <param name="eventTag"></param>
        /// <returns></returns>
        [OperationContract]
        int GetStatusWithEventTag(string eventTag);

        /// <summary>
        /// 获取指定事件标识的发送短信
        /// </summary>
        /// <param name="eventTag"></param>
        /// <returns></returns>
        [OperationContract]
        SendMessage[] GetSendMessageWithEventTag(string eventTag);

        /// <summary>
        /// 搜索发送短信
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        [OperationContract]
        SearchResult<SendMessage> SearchSendMessage(SearchCondition condition);

        /// <summary>
        /// 添加发送短信
        /// </summary>
        /// <param name="sendMessage"></param>
        /// <returns></returns>
        [OperationContract]
        int AddSendMessage(SendMessage sendMessage);

        /// <summary>
        /// 添加发送短信
        /// </summary>
        /// <param name="sendMessages"></param>
        /// <returns></returns>
        [OperationContract]
        int AddSendMessages(SendMessage[] sendMessages);

        /// <summary>
        /// 修改发送短信
        /// </summary>
        /// <param name="sendMessage"></param>
        /// <returns></returns>
        [OperationContract]
        int UpdateSendMessage(SendMessage sendMessage);

        /// <summary>
        /// 修改发送短信
        /// </summary>
        /// <param name="sendMessages"></param>
        /// <returns></returns>
        [OperationContract]
        int UpdateSendMessages(SendMessage[] sendMessages);

        /// <summary>
        /// 删除发送短信
        /// </summary>
        /// <param name="sendKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        int DeleteSendMessage(string sendKeyid);

        /// <summary>
        /// 删除发送短信
        /// </summary>
        /// <param name="sendKeyids"></param>
        /// <returns></returns>
        [OperationContract]
        int DeleteSendMessages(string[] sendKeyids);

        #endregion

        #region ReceiveMessage

        /// <summary>
        /// 获取接收短信
        /// </summary>
        /// <param name="receiveKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        ReceiveMessage GetReceiveMessage(string receiveKeyid);

        /// <summary>
        /// 获取回复的短信
        /// </summary>
        /// <param name="sendKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        ReceiveMessage[] GetReplyMessage(string sendKeyid);

        /// <summary>
        /// 获取回复的接收短信
        /// </summary>
        /// <param name="receiveNumber"></param>
        /// <param name="replyCode"></param>
        /// <returns></returns>
        [OperationContract]
        ReceiveMessage[] GetReplyReceiveMessage(string receiveNumber, string replyCode);

        /// <summary>
        /// 搜索接收短信
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        [OperationContract]
        SearchResult<ReceiveMessage> SearchReceiveMessage(SearchCondition condition);

        /// <summary>
        /// 添加接收短信
        /// </summary>
        /// <param name="receiveMessage"></param>
        /// <returns></returns>
        [OperationContract]
        int AddReceiveMessage(ReceiveMessage receiveMessage);

        /// <summary>
        /// 添加接收短信
        /// </summary>
        /// <param name="receiveMessages"></param>
        /// <returns></returns>
        [OperationContract]
        int AddReceiveMessages(ReceiveMessage[] receiveMessages);

        /// <summary>
        /// 修改接收短信
        /// </summary>
        /// <param name="receiveMessage"></param>
        /// <returns></returns>
        [OperationContract]
        int UpdateReceiveMessage(ReceiveMessage receiveMessage);

        /// <summary>
        /// 修改接收短信
        /// </summary>
        /// <param name="receiveMessages"></param>
        /// <returns></returns>
        [OperationContract]
        int UpdateReceiveMessages(ReceiveMessage[] receiveMessages);

        /// <summary>
        /// 删除接收短信
        /// </summary>
        /// <param name="receiveKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        int DeleteReceiveMessage(string receiveKeyid);

        /// <summary>
        /// 删除接收短信
        /// </summary>
        /// <param name="receiveKeyids"></param>
        /// <returns></returns>
        [OperationContract]
        int DeleteReceiveMessages(string[] receiveKeyids);

        #endregion

        #region SMSMessage

        /// <summary>
        /// 根据发送标识获取短信信息
        /// </summary>
        /// <param name="sendKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        SMSMessage[] GetSendSMSMessage(string sendKeyid);

        /// <summary>
        /// 根据接收标识获取短信信息
        /// </summary>
        /// <param name="receiveKeyid"></param>
        /// <returns></returns>
        [OperationContract]
        SMSMessage GetReceiveSMSMessage(string receiveKeyid);

        /// <summary>
        /// 根据事件标志获取短信信息
        /// </summary>
        /// <param name="eventTag"></param>
        /// <returns></returns>
        [OperationContract]
        SMSMessage[] GetEventTagSMSMessage(string eventTag);

        /// <summary>
        /// 搜索短信信息
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        [OperationContract]
        SearchResult<SMSMessage> SearchSMSMessage(SearchCondition condition);

        #endregion
    }
}